package com.example.demo.service.impl;

import java.util.Collection;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.example.demo.AyUser;
import com.example.demo.repository.AyUserRepository;
import com.example.demo.service.AyUserService;

//用户服务层实现类
@Service // spring boot 会自动扫描到@Component注解的类，并把这些类纳入进Spring容器中管理，也可以用@Component注解

public class AyUserServiceImpl implements AyUserService {
	@Resource
	private AyUserRepository ayUserRepository;

	@Override
	public AyUser findById(String id) {
		return ayUserRepository.findById(id).get();
	}

	@Override
	public List<AyUser> findAll() {
		return ayUserRepository.findAll();
	}

	@Override
	public AyUser save(AyUser ayUser) {
		return ayUserRepository.save(ayUser);
	}

	@Override
	public void delete(String id) {
		ayUserRepository.deleteById(id);
	}

	@Override
	public Page<AyUser> findAll(Pageable pageable) {
		return ayUserRepository.findAll(pageable);
	}
	@Override
	public List<AyUser> findByName(String name)
	{
		return ayUserRepository.findByName(name);
	}
	@Override
	public List<AyUser> findByNameLike(String name)
	{
		return ayUserRepository.findByNameLike(name);
	}
	@Override
	public List<AyUser> findByIdIn(Collection<String> ids)
	{
		return ayUserRepository.findByIdIn(ids);
	}
	
	
}
